const Koa = require('koa')
const static = require('koa-static')
const app = new Koa()
app.listen(3000, () => console.log('http://localhost:3000'))

app.use(static('./www'))

// 中间件  context 全局上下文 它就是一个请求和响应对象的集合体
app.use(async (ctx, next) => {
  console.log(1111)
  await next()
  console.log('aaaa')
})

app.use(async (ctx, next) => {
  console.log(2222)
  await next()
  console.log('bbbb')
})

app.use(async (ctx, next) => {
  console.log(3333)
  await next()
  console.log('cccc')
})

app.use(async ctx => {
  console.log('dddd')
  // 输出 
  // ctx.response.body = '你好koa'
  ctx.body = '<h3>你好koa</h3>'
})



